<template>
	<view style="padding-bottom: 150rpx;" v-if="pageShow">
		<!-- // :0=全部,1=待付款,2=待核销,3=已完成,4=已取消,5=已退费 -->
		<view class="mainpadding flexleft" style="background-color: #1ba95b;min-height: 170rpx;" v-if="dataAll.status==1">
			<view class="">
				<view class="titletext sanshier xiaobai fonweight">待付款</view>
				<view class="xiaobai strongtext margin_top">超时未支付系统将自动取消！</view>
			</view>
		</view>
		<view class="mainpadding flexleft" style="background-color: #1ba95b;min-height: 170rpx;" v-if="dataAll.status==2 && dataAll.pt_status==10">
			<view class="">
				<view class="titletext sanshier xiaobai fonweight">待成团&nbsp;&nbsp;&nbsp;还差{{Number(dataAll.groupinfo.pt_num)-Number(dataAll.groupinfo.join_num)}}人</view>
			</view>
		</view>
		<view class="mainpadding flexleft" style="background-color: #1ba95b;min-height: 170rpx;" v-if="dataAll.status==2 && dataAll.pt_status==20">
			<view class="">
				<view class="titletext sanshier xiaobai fonweight">待核销</view>
			</view>
		</view>
		<view class="mainpadding flexleft" style="background-color: #1ba95b;min-height: 170rpx;"
			v-if="dataAll.status==3 && dataAll.comment_status==1">
			<view class="">
				<view class="titletext sanshier xiaobai fonweight">待评价</view>
				<view class="xiaobai strongtext margin_top">您的评价是我们前进的动力，期待您的评价！</view>
			</view>
		</view>
		<view class="mainpadding flexbetween" style="background-color: #1ba95b;min-height: 170rpx;"
			v-if="dataAll.status==3 && dataAll.comment_status==2">
			<view class="">
				<view class="titletext sanshier xiaobai fonweight">已完成</view>
				<view class="xiaobai strongtext margin_top">订单已完成，期待您的再次光临！</view>
			</view>
			<u-icon name="checkmark-circle-fill" color="#ffffff" size="40"></u-icon>
		</view>
		<view class="mainpadding flexbetween" style="background-color: #1ba95b;min-height: 170rpx;"
			v-if="dataAll.status==4">
			<view class="">
				<view class="titletext sanshier xiaobai fonweight">已取消</view>
				<view class="xiaobai strongtext margin_top">订单被取消，期待下次能和您亲密接触！</view>
			</view>
			<u-icon name="close-circle-fill" color="#ffffff" size="40"></u-icon>
		</view>
		<view class="mainpadding flexbetween" style="background-color: #1ba95b;min-height: 170rpx;"
			v-if="dataAll.status==5">
			<view class="">
				<view class="titletext sanshier xiaobai fonweight">已退费</view>
				<view class="xiaobai strongtext margin_top">期待下次能和您亲密接触！</view>
			</view>
			<u-icon name="close-circle-fill" color="#ffffff" size="40"></u-icon>
		</view>
		<view class="mainpadding flexbetween" style="background-color: #1ba95b;min-height: 170rpx;"
			v-if="dataAll.status==6">
			<view class="">
				<view class="titletext sanshier xiaobai fonweight">退费审核中</view>
				<view class="xiaobai strongtext margin_top">退费审核中，等待机构审核！</view>
			</view>
			<!-- <u-icon name="close-circle-fill" color="#ffffff" size="40"></u-icon> -->
		</view>
		<view class="mainpadding_top ffffff">
			<view class="flexbetween">
				<view class="shilitu margin_right2">
					<image :src="dataAll.image_text" mode=""></image>
				</view>
				<view class="flexcolumn" style="width: 69%;align-items: flex-start;height: 160rpx;justify-content: space-between;">
					<view class="titletext xiaohei fonweight yhxk">{{dataAll.name}}</view>
					<view class="flexleft" >
						<view class="sanshier xiaohong fonweight">￥{{dataAll.pay_price}}</view>
						<view class="sanshier xiaohong fonweight" v-if="Number(dataAll.total_score)">+{{dataAll.total_score}}分</view>
					</view>
				</view>
			</view>
		</view>
		<view class="mainpadding_top ffffff flexcolumn" v-if="dataAll.status==2 && hxewmShow && dataAll.pt_status==20">
			<view class="titletext sanshier fonweight">核销码</view>
			<uqrcode ref="uqrcode" canvas-id="qrcode" @click="ewmfn" v-bind:value="qrcodeurl"
				:options="{ margin: 10}" size="150">
			</uqrcode>
		</view>
		<view class="mainpadding_top ffffff">
			<view class="titletext sanshier fonweight">订单信息</view>
			<view class="flexbetween margin_top">
				<view class="strongtext">订单金额：</view>
				<view class="strongtext">￥{{dataAll.pay_price}}元</view>
			</view>
			<view class="flexbetween margin_top">
				<view class="strongtext">剩余课数：</view>
				<view class="strongtext" style="color: #1ba95b;">{{dataAll.sy_num}}节课</view>
			</view>
			<view class="flexbetween margin_top">
				<view class="strongtext">积分：</view>
				<view class="strongtext">{{dataAll.total_score}}分</view>
			</view>
			<view class="flexbetween margin_top">
				<view class="strongtext">优惠金额：</view>
				<view class="strongtext">￥{{dataAll.coupon_price}}元</view>
			</view>
			<view class="flexbetween margin_top">
				<view class="strongtext">订单编号：</view>
				<view class="strongtext">{{dataAll.order_no}}</view>
			</view>
			<view class="flexbetween margin_top">
				<view class="strongtext">创建时间：</view>
				<view class="strongtext">{{dataAll.createtime_text}}</view>
			</view>
			<view class="flexbetween margin_top">
				<view class="strongtext">支付方式：</view>
				<view class="strongtext">{{returnpayway(dataAll.pay_type)}}</view>
			</view>
		</view>
		<view class="gudingdb ffffff mainpadding">
			<view class="flexbetween" >
				<view class="sanshier xiaohong fonweight flexleft" v-if="dataAll.status==1">
					<u-count-down :time="dataAll.pay_end_time*1000 - Number(new Date())" format="HH:mm:ss"></u-count-down>
					后自动取消
				</view>
				<view class="flexright">
					<view class="baibtn" v-if="dataAll.status==1"  @click="cancelitem(listid)">取消订单</view>
					<view class="lvbtn margin_left" v-if="dataAll.status==1"  @click="payorder(dataAll)">继续付款</view>
				</view>
			</view>
			<view class="flexright">
				<view class="lvbtn margin_left" v-if="dataAll.status==2"  @click="tuifei(listid)">申请退费</view>
				<view class="baibtn" v-if="dataAll.status==4 || dataAll.status==3 || dataAll.status==5" @click.stop="delitem(listid)">删除订单</view>
				<view class="lvbtn margin_left" v-if="dataAll.status==3 && dataAll.comment_status==1" @click="pingjia(listid)">立即评价</view>
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				listid: "",
				dataAll: {},
				pageShow: false,
				qrcodeurl:"",
				hxewmShow:false
			}
		},
		onLoad(options) {
			this.listid = options.id
			this.getsystem()
		},
		onShow() {
			this.getDetail()
			
		},
		methods: {
			pingjia(id){
				uni.navigateTo({
					url:"/pages_mypage/pingjia?type=2&id="+id
				})
			},
			tuifei(id){
				uni.navigateTo({
					url:"/pages_mypage/tuifei?id="+id
				})
			},
			getsystem(){
				uni.showLoading({
					mask:true,
					title:"请稍后"
				})
				httpRequest.request('/api/index/getConfigInfo', 'POST', {
				}, false, false, true).then(res => {
					uni.hideLoading()
					this.qrcodeurl = res.data.kcdzp_url+"?hxid="+this.listid
					this.hxewmShow = true
				})
			},
			// 二维码点击预览图片
			ewmfn() {
				this.$refs.uqrcode.toTempFilePath({
					success: res => {
						console.log(res);
						var i = [res.tempFilePath]; //获取当前页面的轮播图数据
						//uniapp预览轮播图
						uni.previewImage({
							current: 0, //预览图片的下标
							urls: i //预览图片的地址，必须要数组形式，如果不是数组形式就转换成数组形式就可以
						})
					}
				});
			},
			payorder(item) {
				if (Number(item.total_score)) {
					uni.navigateTo({
						url: '/pages_homepage/zhifu?type=3&price=' + item.pay_price + "&id=" +
							item.id + "&total_score=" + item.total_score
					})
				} else {
					uni.navigateTo({
						url: '/pages_homepage/zhifu?type=3&price=' + item.pay_price + "&id=" +
							item.id
					})
				}
			},
			delitem(id) {
				httpRequest.modal('提示', '确认删除当前订单吗？', true, (res) => {
					if (res) {
						httpRequest.request('/api/user/deleteKcOrder', 'POST', {
							id
						}, false, false, true).then(res => {
							httpRequest.toast(res.msg)
							if (res.code == 1) {
								setTimeout(()=>{
									uni.navigateBack(1)
								},1000)
							}
						})
					}
				})
			},
			cancelitem(id) {
				httpRequest.modal('提示', '确认取消当前订单吗？', true, (res) => {
					if (res) {
						httpRequest.request('/api/user/cancelKcOrder', 'GET', {
							id
						}, false, false, true).then(res => {
							httpRequest.toast(res.msg)
							if (res.code == 1) {
								this.getDetail()
							}
						})
					}
				})
			},
			// 10=微信,20=支付宝,30=余额支付,40=平台支付
			returnpayway(val) {
				if (val == 10) return "微信"
				if (val == 20) return "支付宝"
				if (val == 30) return "余额支付"
				if (val == 40) return "平台支付"
			},
			getDetail() {
				httpRequest.request('/api/user/kcOrderDetail', 'GET', {
					id: this.listid
				}, false, false, true).then(res => {
					this.dataAll = res.data
					this.pageShow = true
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	::v-deep.u-count-down__text {
		color: #ff0000
	}
	page{
		background-color: #f9f9f9;
	}
	.shilitu {
		width: 200rpx;
		height: 160rpx;
	
		image {
			width: 100%;
			height: 100%;
		}
	}
</style>
